15. Solution: Dictionaries and Identity Operators

Solution: Define a Dictionary

We can define the dictionary like this:

>>> population = {'Shanghai': 17.8,
              'Istanbul': 13.3,
              'Karachi': 13.0,
              'Mumbai': 12.5}

I chose to put each key-value pair on its own line to make this dictionary definition easier to read, but where and whether you use line breaks is simply a stylistic choice. This code works just as well:

>>> population = {'Shanghai': 17.8, 'Istanbul': 13.3, 'Karachi': 13.0, 'Mumbai': 12.5}